<template>
  <div class="app-container">
    <el-form ref="dataForm" :rules="templateFormRules" :model="templateForm" label-position="left" label-width="140px">
      <el-form-item label="appKey" prop="appKey">
        <el-input v-model="templateForm.appKey" />
      </el-form-item>
      <el-form-item label="appSecret" prop="appSecret">
        <el-input v-model="templateForm.appSecret" />
      </el-form-item>
    </el-form>
    <div slot="footer" class="dialog-footer">
      <el-button @click="handleCannel()">
        取消
      </el-button>
      <el-button type="primary" @click="createData()">
        确认
      </el-button>
    </div>
  </div>
</template>

<script>
import { saveTemplate } from '@/api/logistics/template'

export default {
  name: 'ComplexTable',
  components: { },
  directives: {  },
  filters: {
  },
  data() {
    return {
      templateForm: {
        code: '',
        title: '',
        remark: '',
        keyword:[],
        status: {
          label: '',
          value: 1
        }
      }
    }
  },
  created() {
  },
  methods: {
    handleCannel() {
      this.$router.push({ path: 'template' })
    },
    createData() {
      this.listLoading = true
      const templateForm = this.templateForm
      templateForm.status = templateForm.status.value
      console.log(templateForm)
      if (templateForm.ID > 0) {
        templateForm.templateID = templateForm.ID
      }
      templateForm.keyword = templateForm.keyword.join('>>')
      saveTemplate(templateForm).then(response => {
        if (response.status === 200) {
          this.$message({
            message: '操作Success',
            type: 'success'
          })
          this.$router.push({ path: 'template' })
        } else {
          this.$message({
            message: response.msg,
            type: 'error'
          })
        }
      })
    }
  }
}
</script>
